<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_put".
 *
 * @property string $id
 * @property integer $person
 * @property string $person_openid
 * @property integer $num
 * @property integer $cunid
 * @property string $address
 * @property string $no
 */
class BusinessPut extends \yii\db\ActiveRecord
{


    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '投放计划',      //用于修改了什么的显示
        'mainfield' => 'id',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_put';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['person', 'num', 'cunid', 'no'], 'required'],
            [['person', 'num', 'cunid','createtime'], 'integer'],
            [['person_openid'], 'string', 'max' => 35],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'person' => '业务人',
            'person_openid' => '业务人openid',
            'num' => '数量',
            'cunid' => '村',
            'no' => '投放编号',
            'createtime' => '记录时间',
        ];
    }





    /**
     * @return \yii\db\ActiveQuery
     * 获取业务人
     */
    public function getPutperson()
    {
        return $this->hasOne(BusinessPerson::className(),['id'=>'person']);
    }


    /**
     * @return \yii\db\ActiveQuery
     * 获取村庄
     */
    public function getVillage()
    {
        return $this->hasOne(BusinessAdress::className(),['id'=>'cunid']);
    }


}
